package application

import (
	"ruoyi-go-echo-ddd/internal/domain/model"
	"ruoyi-go-echo-ddd/internal/domain/service"
	"ruoyi-go-echo-ddd/internal/infrastructure/http/request"

	"github.com/labstack/echo/v4"
)

type SysPostApplication struct {
	service *service.SysPostService
}

func NewSysPostApplication(s *service.SysPostService) *SysPostApplication {
	return &SysPostApplication{
		service: s,
	}
}

func (s *SysPostApplication) Insert(c echo.Context, sysPost *model.SysPost) (*model.SysPost, error) {
	return s.service.Insert(c.Request().Context(), sysPost)
}

func (s *SysPostApplication) Update(c echo.Context, sysPost *model.SysPost) (int64, error) {
	return s.service.Update(c.Request().Context(), sysPost)
}

func (s *SysPostApplication) BatchInsert(c echo.Context, list []*model.SysPost) ([]int64, error) {
	return s.service.BatchInsert(c.Request().Context(), list)
}

func (s *SysPostApplication) SelectById(c echo.Context, id int64) (*model.SysPost, error) {
	return s.service.SelectById(c.Request().Context(), id)
}

func (s *SysPostApplication) SelectPage(c echo.Context, param *request.PostPageParam) ([]*model.SysPost, int64, int64, error) {
	return s.service.SelectPage(c.Request().Context(), param)
}

func (s *SysPostApplication) BatchDelete(c echo.Context, ids []any) (int64, error) {
	return s.service.BatchDelete(c.Request().Context(), ids)
}

func (s *SysPostApplication) SelectPostIdsByUserId(c echo.Context, userId int64) ([]int64, error) {
	return s.service.SelectPostIdsByUserId(c.Request().Context(), userId)
}

func (s *SysPostApplication) SelectPostNameListByIds(c echo.Context, ids []int64) ([]string, error) {
	return s.service.SelectPostNameListByIds(c.Request().Context(), ids)
}

func (s *SysPostApplication) SelectAll(c echo.Context) ([]*model.SysPost, error) {
	return s.service.SelectAll(c.Request().Context())
}

func (s *SysPostApplication) DeleteByUserId(c echo.Context, userId int64) (int64, error) {
	return s.service.DeleteByUserId(c.Request().Context(), userId)
}

func (s *SysPostApplication) DeleteByUserIdList(c echo.Context, userIds []int64) (int64, error) {
	return s.service.DeleteByUserIdList(c.Request().Context(), userIds)
}
